<template>
  <div>
    <!--    表格-->
    <el-table :data="orderTypeData.items">
      <el-table-column label="物品类型名称" prop="name"/>
      <el-table-column label="默认重量(千克)" prop="defaultWeight"/>
      <el-table-column label="默认体积(方)" prop="defaultVolume"/>
      <el-table-column label="备注" prop="remark"/>
      <el-table-column label="车辆类型" prop="truckTypeIds">
        <template slot-scope="scope">
          <el-select v-model="scope.row.truckTypeIds" multiple placeholder="请选择" disabled>
            <el-option
              v-for="item in truckType"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="状态" prop="status">
        <template slot-scope="scope">
          <p v-if="scope.row.status==0">禁用</p>
          <p v-if="scope.row.status==1">正常</p>
        </template>
      </el-table-column>
    </el-table>

    <!--    分页-->
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="Number(orderTypeData.page)"
      :page-sizes="[5, 10, 30, 50]"
      :page-size="Number(orderTypeData.pageSize)"
      layout="total, sizes, prev, pager, next, jumper"
      :total="Number(orderTypeData.counts)"
    >
    </el-pagination>
  </div>
</template>

<script>
import orderType from '@/api/base/orderType/index'

export default {
  name: 'index',
  data() {
    return {
      truckType: [],
      pageNum: 1,
      pageSize: 5,
      orderTypeData: {}
    }
  },
  methods: {
    getAllTruckType() {
      orderType.getAllTruckType().then(data => {
        this.truckType = data.data
      })
    },
    handleSizeChange(val) {
      this.pageSize = val
      this.findOrderTypePage()
    },
    handleCurrentChange(val) {
      this.pageNum = val
      this.findOrderTypePage()
    },
    findOrderTypePage() {
      orderType.findOrderTypePage(this.pageNum, this.pageSize).then(data => {
        this.orderTypeData = data.data
      })
    }
  }, mounted() {
    this.findOrderTypePage()
    this.getAllTruckType()
  }
}
</script>

<style scoped>

</style>
